package com.davemorrissey.labs.subscaleview.entry.slice;

import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import com.davemorrissey.labs.subscaleview.entry.ResourceTable;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        Text text1 = (Text) findComponentById(ResourceTable.Id_text1);
        Text text2 = (Text) findComponentById(ResourceTable.Id_text2);
        Text text3 = (Text) findComponentById(ResourceTable.Id_text3);
        SubsamplingScaleImageView subsamplingScaleImageView =
                (SubsamplingScaleImageView) findComponentById(ResourceTable.Id_img);
        text1.setClickedListener(
                new Component.ClickedListener() {
                    @Override
                    public void onClick(Component component) {
                        subsamplingScaleImageView.setResPixelMap(ResourceTable.Media_card);
                    }
                });

        text3.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                subsamplingScaleImageView.setResPixelMap(ResourceTable.Media_long_image);
            }
        });

        text2.setClickedListener(
                new Component.ClickedListener() {
                    @Override
                    public void onClick(Component component) {
                        subsamplingScaleImageView.setUrlPixelMap("https://www.harmonyos.com/resource/image/community/shanghai.jpg");
                    }
                });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
